#include "Context.hpp"
#include "EmptyState.hpp"

Context::Context()
{
    state = make_shared<EmptyState>();
}

void Context::setState(shared_ptr<State> new_state)
{
    // 新状态执行，传入旧状态
    new_state.get()->doAction(this, state);
    // 为上下文对象设置新状态
    state = new_state;
}

shared_ptr<State> Context::getState()
{
    return state;
}
